package com.htgd.gardenexpo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.htgd.gardenexpo.dao.GeConTouristTrafficMapper;
import com.htgd.gardenexpo.entity.GeConTouristTraffic;
import com.htgd.gardenexpo.page.TouristTrafficQuery;
import com.htgd.gardenexpo.service.GeBaseDictService;
import com.htgd.gardenexpo.service.GeConTouristTrafficService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GeConTouristTrafficServiceImpl extends ServiceImpl<GeConTouristTrafficMapper, GeConTouristTraffic> implements GeConTouristTrafficService {

    @Autowired
    private GeConTouristTrafficMapper geConTouristTrafficMapper;

    @Autowired
    private GeBaseDictService geBaseDictService;

    @Override
    public PageInfo<GeConTouristTraffic> pageList(TouristTrafficQuery touristTrafficQuery) {
        PageHelper.startPage(touristTrafficQuery.getPageNum(), touristTrafficQuery.getPageSize());
        List<GeConTouristTraffic> list= geConTouristTrafficMapper.pageList(touristTrafficQuery);
        for (GeConTouristTraffic geConTouristTraffic : list) {
            if(geConTouristTraffic.getStatus()!=null){
                geConTouristTraffic.setStatusText(geBaseDictService.getStatusText(String.valueOf(geConTouristTraffic.getStatus())));
            }
            if(geConTouristTraffic.getIsTop()!=null){
                geConTouristTraffic.setIsTopText(geBaseDictService.getTopText(String.valueOf(geConTouristTraffic.getIsTop())));
            }
        }
        return new PageInfo<>(list);
    }
}
